package com.shop.rabbit.rabbitmq.config;

import cn.common.constant.RabbitConstants;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


@Configuration
public class RabbitConfig {

    @Bean
    public Queue registerQueue() {
        return new Queue(RabbitConstants.QUEUE_NAME, true, false, false);
    }
    @Bean
    public DirectExchange registerExchange() {
        return new DirectExchange(RabbitConstants.EXCHANGE_NAME, true, false);
    }
    @Bean
    public Binding registerBinding() {
       return BindingBuilder.bind(registerQueue()).to(registerExchange()).with(RabbitConstants.ROUTING_KEY);
    }


    @Bean
    public Queue wallerQueue() {
        return new Queue(RabbitConstants.QUEUE_WALLER, true, false, false);
    }
    @Bean
    public DirectExchange wallerExchange() {
        return new DirectExchange(RabbitConstants.EXCHANGE_WALLER, true, false);
    }
    @Bean
    public Binding wallerBinding() {
        return BindingBuilder.bind(wallerQueue()).to(wallerExchange()).with(RabbitConstants.ROUTING_KEY_WALLER);
    }

    @Bean
    public Queue consumeQueue() {
        return new Queue(RabbitConstants.CONSUME_CURRENCY_QUEUE_PUT, true, false, false);
    }
    @Bean
    public DirectExchange consumeExchange() {
        return new DirectExchange(RabbitConstants.CONSUME_CURRENCY_EXCHANGE_PUT, true, false);
    }
    @Bean
    public Binding consumeBinding() {
        return BindingBuilder.bind(consumeQueue()).to(consumeExchange()).with(RabbitConstants.CONSUME_CURRENCY_ROUTING_PUT);
    }


    @Bean
    public Queue matchQueue() {
        return new Queue(RabbitConstants.MATCH_PRODUCER_QUEUE_PUT, true, false, false);
    }
    @Bean
    public DirectExchange matchExchange() {
        return new DirectExchange(RabbitConstants.MATCH_PRODUCER_EXCHANGE_PUT, true, false);
    }
    @Bean
    public Binding matchBinding() {
        return BindingBuilder.bind(matchQueue()).to(matchExchange()).with(RabbitConstants.MATCH_PRODUCER_ROUTING_PUT);
    }

    @Bean
    public Queue entrustQueue() {
        return new Queue(RabbitConstants.ENTRUST_PROJECT_MATCH_QUEUE_PUT, true, false, false);
    }
    @Bean
    public DirectExchange entrustExchange() {
        return new DirectExchange(RabbitConstants.ENTRUST_PROJECT_MATCH_PUT, true, false);
    }
    @Bean
    public Binding entrustBinding() {
        return BindingBuilder.bind(entrustQueue()).to(entrustExchange()).with(RabbitConstants.ENTRUST_PROJECT_MATCH_ROUTINGKEY_PUT);
    }


    @Bean
    public Queue entrustBalanceQueue() {
        return new Queue(RabbitConstants.ENTRUST_BALANCE_QUEUE_PUT, true, false, false);
    }
    @Bean
    public DirectExchange entrustBalanceExchange() {
        return new DirectExchange(RabbitConstants.ENTRUST_BALANCE_PUT, true, false);
    }
    @Bean
    public Binding entrustBalanceBinding() {
        return  BindingBuilder.bind(entrustBalanceQueue()).to(entrustBalanceExchange()).with(RabbitConstants.ENTRUST_BALANCE_ROUTINGKEY_PUT);
    }
}
